package com.wontube.smr.web.pub;

import java.util.HashMap;

public final class RequestHeadersHolder {
	private RequestHeadersHolder() {
	}

	public static final RequestHeadersHolder holder = new RequestHeadersHolder();
	public static final String sessionKey = "WONTUBE_SESSIONID";
	public static final String ipKey = "X-Real-IP";

	private final ThreadLocal<HashMap<String, String>> __header = new ThreadLocal<HashMap<String, String>>();
	
	public HashMap<String, String> getHeader() {
		HashMap<String, String> header = this.__header.get();
		if (header == null) {
			header = new HashMap<String, String>();
			this.__header.set(header);
		}
		return header;
	}
	
	public String getSessionId() {
		HashMap<String, String> header = this.getHeader();
		return header.get(sessionKey);
	}
	
	public String getRealIP() {
		HashMap<String, String> header = this.getHeader();
		return header.get(ipKey);
	}
	
	public void setHeaders(HashMap<String, String> value) {
		this.__header.set(value);
	}
	
	public void remove() {
		this.__header.remove();
	}
}




